<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>returnOrderItem管理</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">

    <!-- 上传图片框样式，不使用上传组件可以删除此样式 -->
    <style>
        .avatar-uploader .el-upload {
            border: 1px dashed #d9d9d9;
            border-radius: 6px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }
        .avatar-uploader .el-upload:hover {
            border-color: #409EFF;
        }
        .avatar-uploader-icon {
            font-size: 28px;
            color: #8c939d;
            width: 150px;
            height: 70px;
            line-height: 150px;
            text-align: center;
        }
        .avatar {
            width: 150px;
            height: 70px;
            display: block;
        }

    </style>
</head>
<body class="hold-transition">
<div id="app">

    <div class="content-header">
        <h1>管理<small>returnOrderItem管理</small></h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>管理</el-breadcrumb-item>
            <el-breadcrumb-item>returnOrderItem管理</el-breadcrumb-item>
        </el-breadcrumb>
    </div>

    <div class="app-container">
        <el-button @click="goBack()" icon="el-icon-arrow-left" type="primary" >返回</el-button>
        <p></p>
        <div class="box">
            <el-form label-width="120px">
                <el-form-item label="服务单号">
                    <span>{{pojo.id}}</span>
                </el-form-item>
                <el-form-item label="申请状态">
                    <span v-if="pojo.status==0">待处理</span>
                    <span v-else-if="pojo.status==1">已完成</span>
                    <span v-else>已驳回</span>
                </el-form-item>
                <el-form-item label="SKU_ID">
                    <span>{{pojo.skuId}}</span>
                </el-form-item>
                <el-form-item label="订单编号">
                    <span>{{pojo.orderId}}</span>
                </el-form-item>
                <el-form-item label="申请时间">
                    <span>{{pojo.applyTime}}</span>
                </el-form-item>
                <el-form-item label="用户账号">
                    <span>{{pojo.userAccount}}</span>
                </el-form-item>
            </el-form>
        </div>
        <div class="box">
            <el-form label-width="120px">
                <el-form-item label="订单金额">
                    <span>{{pojo.returnMoney}}</span>
                </el-form-item>
                <el-form-item label="确认退款金额">
                    <span>{{pojo.returnMoney}}</span>
                </el-form-item>
                <el-form-item label="退款方式">
                    <span>退回到原支付渠道</span>
                </el-form-item>
                <el-form-item label="退款类型">
                    <span>取消订单</span>
                </el-form-item>
                <el-form-item label="退款原因">
                    <span>{{pojo.returnCause}}</span>
                </el-form-item>
            </el-form>
        </div>
        <div class="box" v-if="this.pojo.status==0">
            <el-form label-width="80px">
                <el-form-item label="处理详情备注">
                    <el-input v-model="pojo.remark"></el-input>
                </el-form-item>
                <div style="text-align: center">
                    <el-form-item>
                        <el-button type="primary" @click="agreeRefund()">
                            <span v-if="pojo.type=='2'">确认退款</span>
                            <span v-else>确认退货</span>
                        </el-button>
                        <el-button type="danger" @click="rejectRefund()" >
                            <span v-if="pojo.type=='2'">拒绝退款</span>
                            <span v-else>拒绝退货</span>
                        </el-button>
                    </el-form-item>
                </div>

            </el-form>
        </div>
    </div>


</div>
</body>
<script src="/js/vue.js"></script>
<script src="/js/axios.js"></script>
<script src="/js/elementui.js"></script>
<script src="/js/util.js"></script>
<script>
     new Vue({
        el: '#app',
        data(){
            return {
                tableData: [],
                currentPage: 1,
                total: 10,
                size: 10,
                searchMap: {},
                pojo: {},
                formVisible: false,
                imageUrl: '',
                returnid:''
            }
        },
        created(){
            this.returnid = getQueryString("id");
            console.log(this.returnid);
            this.fetchData();
        },
        methods:{
            goBack(){
                location.href = "returnOrder.html";
            },
            rejectRefund(){
                axios.get(`/returnOrder/rejectRefund.do?id=${this.pojo.id}&remark=${this.pojo.remark}`).then(response => {
                    this.pojo = response.data;
                    console.log(this.pojo);
                });
            },
            agreeRefund(){
                axios.get(`/returnOrder/agreeRefund.do?id=${this.pojo.id}&money=${this.pojo.returnMoney}`).then(response => {
                    this.pojo = response.data;
                    console.log(this.pojo);
                });
            },
            fetchData (){
                axios.get(`/returnOrder/findById.do?id=${this.returnid}`).then(response => {
                    this.pojo = response.data;
                    console.log(this.pojo);
                });
            },
            save (){
                // this.pojo.image= this.imageUrl; //如页面有图片上传功能放开注释
                axios.post(`/returnOrderItem/${this.pojo.id==null?'add':'update'}.do`,this.pojo).then(response => {
                    this.fetchData (); //刷新列表
                    this.formVisible = false ;//关闭窗口
                });
            },
            edit (id){
                this.formVisible = true // 打开窗口
                // 调用查询
                axios.get(`/returnOrderItem/findById.do?id=${id}`).then(response => {
                    this.pojo = response.data;
                    // this.imageUrl=this.pojo.image //显示图片  如页面有图片上传功能放开注释
                })
            },
            dele (id){
                this.$confirm('确定要删除此记录吗?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then( () => {
                    axios.get(`/returnOrderItem/delete.do?id=${id}`).then(response => {
                        this.fetchData (); //刷新列表
                    })
                })
            },
			/* ****图片上传相关代码  如页面有图片上传功能放开注释 **** 
            handleAvatarSuccess(res, file) {
                this.imageUrl = file.response;
            },
            beforeAvatarUpload(file) {
                const isJPG = file.type === 'image/jpeg';
                const isLt2M = file.size / 1024 / 1024 < 2;

                if (!isJPG) {
                    this.$message.error('上传头像图片只能是 JPG 格式!');
                }
                if (!isLt2M) {
                    this.$message.error('上传头像图片大小不能超过 2MB!');
                }
                return isJPG && isLt2M;
            }*/
        }
    })
</script>
</html>
